package com.paul.inventoryitem.valueobject;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Future;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
  
@Entity  
@Table(name="tb_inventory_item")  
public class InventoryItem implements Serializable {  
  
    private static final long serialVersionUID = 1L;  
      
    @Id    
    @GeneratedValue(strategy=GenerationType.IDENTITY)   
    protected int id;  
      
    @NotNull  
    protected BigDecimal price = new BigDecimal("0.00");      
      
    @NotNull(message = "Name is a required field")  
    protected String name;  
      
    @Min(100)  
    protected int minimumPrice;  
  
//    @Email  
    private String mail;  
  
    @Pattern(regexp="[a-z]+")  
    private String lowerCaseName;  
      
    @Future  
    @Temporal(TemporalType.DATE)
    private Date futureDate;  
  
    @AssertTrue  
    private boolean mustBeTrue;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getMinimumPrice() {
		return minimumPrice;
	}

	public void setMinimumPrice(int minimumPrice) {
		this.minimumPrice = minimumPrice;
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getLowerCaseName() {
		return lowerCaseName;
	}

	public void setLowerCaseName(String lowerCaseName) {
		this.lowerCaseName = lowerCaseName;
	}

	public Date getFutureDate() {
		return futureDate;
	}

	public void setFutureDate(Date futureDate) {
		this.futureDate = futureDate;
	}

	public boolean isMustBeTrue() {
		return mustBeTrue;
	}

	public void setMustBeTrue(boolean mustBeTrue) {
		this.mustBeTrue = mustBeTrue;
	}  
	
	public InventoryItem clone()
	{
		InventoryItem inventoryItem2 = new InventoryItem();
		inventoryItem2.setFutureDate(this.getFutureDate());
		inventoryItem2.setLowerCaseName(this.getLowerCaseName());
		inventoryItem2.setMail(this.getMail());
		inventoryItem2.setMinimumPrice(this.getMinimumPrice());
		inventoryItem2.setMustBeTrue(true);
		inventoryItem2.setName(this.getName());
		inventoryItem2.setPrice(this.getPrice());
		return inventoryItem2;
	}
  
/*    @OneToMany  
    @JoinTable(name="tb_order_items_to_images")  
    @Valid  
    protected List<InventoryImage> images = new ArrayList<InventoryImage>(); */ 
      
      
    // setters/getters here...  
}  